﻿
using UnityEngine;
using System.Collections;

public class Shoot : MonoBehaviour {

    public float bulletDensity = 0.2f;
    public float bulletStartTime = 0;
    public GameObject bullet;
    private GameObject bullets;

    void Awake()
    {
        bullets = GameObject.Find("Bullets");
    }
	// Use this for initialization
	void Start () {
        OpenFire();
    }

    // Update is called once per frame
    void Update () {

    }

    void CreateBullet()
    {
        GameObject bulletObject = Instantiate(bullet, transform.position, Quaternion.identity) as GameObject;
        bulletObject.transform.parent = bullets.transform;

    }

    void OpenFire()
    {
        InvokeRepeating("CreateBullet", bulletStartTime, bulletDensity);
    }

}
